package someTestExcemple.thread.communication;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class BlockingQueueExp {
    public static void main(String[] args) {

        BlockingQueue<String> blockingQueue = new ArrayBlockingQueue<>(1024);

        Consumer consumer = new Consumer(blockingQueue);
        Producer producer = new Producer(blockingQueue);

        // 启动
        producer.start();
        consumer.start();

        /*
         输出:
            Put value:0
            获取队首元素:0
            阻塞时长:4
            Put value:1
            获取队首元素:1
            阻塞时长:1008
            Put value:2
            获取队首元素:2
            阻塞时长:1004
            Put value:3
            获取队首元素:3
            阻塞时长:1016
            Put value:4
            获取队首元素:4
            阻塞时长:1012
        */
    }
}
